package com.hxzy.fleet.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.hxzy.authentication.mapper.TsVehicleCertificationMapper;
import com.hxzy.fleet.entity.TtVehicleInformation;
import com.hxzy.fleet.mapper.TtVehicleInformationMapper;
import com.hxzy.fleet.service.TtVehicleInformationService;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xx
 * @since 2023-06-26
 */
@DataSource(DataSourceType.FLEET)
@Service
public class TtVehicleInformationServiceImpl extends ServiceImpl<TtVehicleInformationMapper, TtVehicleInformation> implements TtVehicleInformationService {
    @Autowired
    private TsVehicleCertificationMapper tsVehicleCertificationMapper;

    @Autowired
    private TtVehicleInformationMapper ttVehicleInformationMapper;
    @Override
    public List<TtVehicleInformation> getttVehicleInformation(TtVehicleInformation ttVehicleInformation) {
        QueryWrapper<TtVehicleInformation> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(Objects.nonNull(ttVehicleInformation.getLicensePlateNumber()),"license_plate_number",ttVehicleInformation.getLicensePlateNumber());
        queryWrapper.eq(Objects.nonNull(ttVehicleInformation.getCarOwner()),"car_owner",ttVehicleInformation.getCarOwner());
        queryWrapper.eq(Objects.nonNull(ttVehicleInformation.getCarType()),"car_type",ttVehicleInformation.getCarType());
        queryWrapper.eq(Objects.nonNull(ttVehicleInformation.getEnergyType()),"energy_type",ttVehicleInformation.getEnergyType());
        queryWrapper.eq(Objects.nonNull(ttVehicleInformation.getUnloadingType()),"unloading_type",ttVehicleInformation.getUnloadingType());
        queryWrapper.eq(Objects.nonNull(ttVehicleInformation.getTransportationStatus()),"transportation_status",ttVehicleInformation.getTransportationStatus());
        List<TtVehicleInformation> ttVehicleInformations = baseMapper.selectList(queryWrapper);
        if (ttVehicleInformations!=null){

            return ttVehicleInformations;
        }
        return null;

    }


    @Override
    public List<TtVehicleInformation> getQueryList(TtVehicleInformation ttVehicleInformation) {
        QueryWrapper<TtVehicleInformation> wrapper=new QueryWrapper<>();
        wrapper.eq(Objects.nonNull(ttVehicleInformation.getCarId()),"car_id",ttVehicleInformation.getCarId());
        wrapper.eq(Objects.nonNull(ttVehicleInformation.getUnloadingType()),"unloading_type",ttVehicleInformation.getUnloadingType());
        wrapper.eq(Objects.nonNull(ttVehicleInformation.getTransportationStatus()),"transportation_status",ttVehicleInformation.getTransportationStatus());
        List<TtVehicleInformation> ttVehicleInformations = ttVehicleInformationMapper.selectList(wrapper);
        return ttVehicleInformations;
    }



}
